package com.ctg.payroll2.dao.extinterface;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ctg.payroll2.action.cusadmin.CompanyAction;
import com.ctg.payroll2.bean.po.PbEmployee;
import com.ctg.payroll2.bean.po.PbEmployeeTmp;
import com.ctg.payroll2.service.cusadmin.PbCompanyService;
import com.ctg.payroll2.service.workflow.WorkflowRoleService;
import com.ctg.payroll2.service.xlsImport.ExeclCustomizeService;
import com.ctg.payroll2.service.xlsImport.XlsImportService;
import com.ctg.payroll2.util.Constants;
import com.ctg.payroll2.util.xlsImport.JxlUtils;

public class MyTest {

	/**
	 * @param args
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		ApplicationContext context = new ClassPathXmlApplicationContext(
				"com/ctg/payroll2/dao/extinterface/applicationContext.xml");
		// XlsImportService<PbEmployeeTmp> es = (XlsImportService) context
		// .getBean("xlsImportService");
		//
		// ExeclCustomizeService es1 = (ExeclCustomizeService) context
		// .getBean("customizeService");
		//
		// PbCompanyService companyService = (PbCompanyService) context
		// .getBean("companyService");

		WorkflowRoleService ws = (WorkflowRoleService) context
				.getBean("workflowRoleService");

		System.out.println(ws == null ? "game over" : " Ok!");

		HashMap<String, Object> map = new HashMap<String, Object>();
		// map.put("employee_id", "57");
		// map.put("period", "200908");
		// map.put("company_code", "409313");
		// map.put("pay_classitem_id", "10000000040");
		// es.payClassIsOnly(map);
		try {
			/*Pattern pattern = Pattern
					.compile("^[1-3][0-9][0-9][0-9][0-1][0-9]$");
			Matcher matcher = pattern.matcher("200912");
			boolean b = matcher.matches();
			System.out.println(b);*/
			
			
			Trone ts = new Trone();
			Thread t = new Thread(ts);
			
			t.run();
			
			for(int i=0;i<=10000000;i++){
				if( i==10000000){
				t.destroy();	
				}
				
			}
			
			

			/*
			 * map.put("flow_roleid", 1); map.put("flow_userid",1);
			 * ws.deleteRoleUser(map);
			 */
			// map.put("company_code", 555555);
			//
			// map.put("creator_id", 1);
			//
			// map.put("create_code", 1);
			//
			// companyService.insertCsKey(map);
			// companyService.deleteCsKey("555555");
			// List<HashMap<String, Object>> sropList = companyService
			// .select_hisstop(map);
			// String stopStr = "";
			// for (HashMap<String, Object> hashMap : sropList) {
			// stopStr +="停用原因 : "+ hashMap.get("END_REASON") + "\n停用时间 : "
			// + hashMap.get("END_TIME") + "\n停用人 : "
			// + hashMap.get("END_USER") + "\n\n";
			// }
			// System.out.println(companyService.isSig("23411234321"));
			// String filePath = "d:\\Pb_employee.xls";
			//
			// HashMap paraMap = new HashMap();
			// HashMap mapping = new HashMap();
			//
			// paraMap.put("ex_interfaceid", 3);
			// // paraMap.put("ex_publictype", ex_publictype);
			// mapping = es.getMappingToBean(paraMap);
			//
			// if ("" != filePath) {
			// try {
			// Map<String, List<Map<String, String>>> map = es
			// .importDataByJxlToList(filePath, mapping);
			// List<Map<String, String>> goodlist = map
			// .get("Good.Records");
			// if (goodlist.size() > 0) {
			// es.executeSql(es.createSql(goodlist));
			// es.update_imp_table();
			// System.out.println( "华丽的分割线----:"+es.createsql2compensation(null,
			// 1000000020, "payment").get(Constants.BAD_LIST).size());
			// }
			// } catch (Throwable e) {
			// e.printStackTrace();
			// }
			// }
			// es1.queryInterfaceMaster(map, 0,100);
			// es1.queryInterfaceDetailsl(null,0, 100);
			// es1.deleteInterFaceDetailsl(103);
			// es.importDataByJxlToList("d:\\Pb_employee.xls", es
			// .getMappingToBean(map));
			// es.createsql2compensation(null, 1000000020,"");
			// Map<String,List> arrylistmap =
			// map.put("ex_interfaceid", 1161);
			// es.importDataList(es.importDataByJxlToBean("d:\\雇员导入测试.xls",
			// PbEmployeeTmp.class, es.getMappingToBean(map)).get(
			// JxlUtils.GOODRECORES));
			// HashMap<String, Object> pm = new HashMap<String, Object>();
			// pm.put("companyCode", 409313);
			// es.insertJTmp2Formal(PbEmployeeTmp.class, pm);
			// HashMap<String, Object> pm = new HashMap<String, Object>();
			// pm.put("companyCode", 409313);
			//			
			// es.insertJTmp2Formal(PbEmployee.class, pm);
			//			
			// List<Map<String,String>> badlist=arrylistmap.get("Bad.Records");
			// for (Map map2 : badlist) {
			// for (Iterator<Entry<String, Object>> it = map2.entrySet()
			// .iterator(); it.hasNext();) {
			// Entry entry = it.next();
			// System.out.println(entry.getKey() + ":" + entry.getValue());
			// }
			// }
		} catch (Throwable e) {
			e.printStackTrace();
		}

	}

	public static void printOne() {
		String[] aa = new String[] { "COMPANY_CODE", "COMPANY_ENGLISH_CODE",
				"COMPANY_CHINESE_CODE", "ENTERPRISE_CODE",
				"COMPANY_SHORT_NAME", " IS_LISTED", "COMPANY_PROPERTY",
				"COMPANY_TYPE", "INDUSTRY_TYPE", "COMPANY_URL",
				"REGISTER_ADDRESS", "BANK", "BANK_ACCOUNT",
				"CORPORATION_REPRESENTATIVE", "REGISTER_CAPITAL", "IS_VAILD",
				"ADDRESS", "PHONE", "FAX", "POSTCODE", "LINK_NAME",
				"LINK_PHONE", "LINK_FAX", "LINK_POSITSION", "STATUS",
				"START_DATE", "END_DATE ", "START_ACCOUNT", "END_ACCOUNT",
				"CREATOR_ID", "CREATE_CODE", "CREATE_DATE", "CREATOR_IP",
				"MODIFIER_ID", "MODIFIER_CODE", "MODIFIER_DATE", "MODIFIER_IP" };
		String[] bb1 = new String[] { "EX_SUB_INTERFACEID", "EX_INTERFACEID",
				"CLASSITEM_ID", "COL_NUM", "EX_SUB_CODE" };
		String[] bb = new String[] { "exSubInterfaceId", "exInterfaceId",
				"classItemId", "cloNum", "exSubCode" };
		for (int i = 0; i < bb1.length; i++) {
			String str = "<isNotNull prepend=\",\" property=\"" + bb[i]
					+ "\" >     " + bb1[i] + " </isNotNull> ";
			// String str="pb_company."+aa[i]+",";

			System.out.println(str);
		}
		System.out.println("华丽的分割线------------------------------------------");
		for (int i = 0; i < bb1.length; i++) {
			String str = "<isNotNull prepend=\",\" property=\"" + bb[i]
					+ "\" >     " + bb1[i] + "= #  " + bb[i]
					+ "   #</isNotNull> ";
			// String str="pb_company."+aa[i]+",";

			System.out.println(str);
		}
		System.out.println("华丽的分割线------------------------------------------");
		for (int i = 0; i < bb.length; i++) {
			String str = "<isNotNull prepend=\",\" property=\"" + bb[i]
					+ "\" >       #" + bb[i] + "#</isNotNull> ";
			// String str="pb_company."+aa[i]+",";

			System.out.println(str);
		}

	}

	public Object getBean(ApplicationContext context, String beanName) {
		return context.getBean(beanName);
	}
}

 
	 